package com.tencent.wxpay.demo.service.impl;

import com.tencent.wxpay.WXPay;
import com.tencent.wxpay.demo.listener.DownloadBillListener;
import com.tencent.wxpay.demo.service.DownloadBillService;
import com.tencent.wxpay.demo.util.TestUtil;
import com.tencent.wxpay.protocol.request.DownloadBillReqData;
import org.springframework.stereotype.Service;

@Service
public class DownloadBillServiceImpl implements DownloadBillService {

    @Override
    public Object doDownloadBill(String billDate, DownloadBillReqData.BillType billType) {
        try{
            DownloadBillReqData downloadBillReqData = new DownloadBillReqData(billDate, billType);
            Object result = WXPay.doDownloadBillBusiness(downloadBillReqData,new DownloadBillListener());
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        if(TestUtil.init()){
            try{
                DownloadBillService downloadBillService = new DownloadBillServiceImpl();
                Object o = downloadBillService.doDownloadBill("20161017", DownloadBillReqData.BillType.ALL);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
